package com.dude.objects;


import java.util.ArrayList;

import com.dude.R;
import com.dude.R.id;
import com.dude.R.layout;
import com.dude.R.raw;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/* the class provides an arrayAdapter specialized for showing a list where each item 
 * contains a text a 1 out of 2 possible icons. it will be used in Profiles class.
 */
public class ProfilesArrayAdapter extends ArrayAdapter<GenericPair<String, Boolean>>{
	
	protected Context context;
	protected ArrayList<GenericPair<String, Boolean>> values;

	public ProfilesArrayAdapter(Context context, ArrayList<GenericPair<String, Boolean>> values) {
		super(context, R.layout.image_and_text_list_item, values);
	    this.context = context;
	    this.values = values;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
	    LayoutInflater inflater = (LayoutInflater) context
	        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	    View rowView = inflater.inflate(R.layout.image_and_text_list_item, parent, false);
	    TextView textView = (TextView) rowView.findViewById(R.id.txt_id);
	    ImageView imageView = (ImageView) rowView.findViewById(R.id.img_id);	    	    
	    textView.setText(values.get(position).getFirst());
	    // Change the icon for single object and multi object
	    boolean single = values.get(position).getSecond();
	    if (single)
	    	imageView.setImageResource(R.drawable.icon_s);
	    else
	    	imageView.setImageResource(R.drawable.icon_m2);
	    return rowView;
	  }
	
	
}
